SET(TARGET_NAME "doxmlparser")
SET(TARGET_DIR "bin/${FLAVOR}/modules")

INCLUDE_DIRECTORIES (../include)
INCLUDE_DIRECTORIES (qtools)

INCLUDE_DIRECTORIES(${LUA_INC_DIR})
LINK_DIRECTORIES (${LUA_LIB_DIR})

ADD_DEFINITIONS(-DPLUG_LIBRARY)
ADD_DEFINITIONS(-DLUNA_BINDINGS)
ADD_DEFINITIONS(-DCXX_ENABLED)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)

# ADD_DEFINITIONS(-DQT_LARGEFILE_SUPPORT)
ADD_DEFINITIONS(-DQT_LITE_UNICODE)

FILE(GLOB_RECURSE PUBLIC_HEADERS "../include/*.h")

FILE(GLOB_RECURSE SOURCE_FILES "parser/*.cpp" "qtools/*.cpp" "*plug_common.cpp" "luna/*.cpp")
# FILE(GLOB_RECURSE SOURCE_FILES "*.cpp" )

file(GLOB_RECURSE to_remove "*plug_common.cpp")
list(REMOVE_ITEM SOURCE_FILES ${to_remove})
ADD_MSVC_PRECOMPILED_HEADER("plug_common.h" "plug_common.cpp" SOURCE_FILES)

ADD_LUNA_FILES(SOURCE_FILES) # Add the Luna files after adding precompiled header.

IF(WIN32)
    # file(GLOB_RECURSE to_remove "*unix.cpp")
    # list(REMOVE_ITEM SOURCE_FILES ${to_remove})
    FILE(GLOB_RECURSE SPECIFIC_SOURCE_FILES "win32/*.cpp")
ELSE()
    # file(GLOB_RECURSE to_remove "*win32.cpp")
    # list(REMOVE_ITEM SOURCE_FILES ${to_remove})
    FILE(GLOB_RECURSE SPECIFIC_SOURCE_FILES "unix/*.cpp")
ENDIF()

ADD_LIBRARY (${TARGET_NAME} SHARED ${PUBLIC_HEADERS} ${SPECIFIC_SOURCE_FILES} ${SOURCE_FILES})

TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LUA_LIBS})  

SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES 
	PREFIX ""
	SUFFIX ".sgp")
    
INSTALL(TARGETS ${TARGET_NAME}
	RUNTIME DESTINATION ${TARGET_DIR}
	LIBRARY DESTINATION ${TARGET_DIR})

# step needed for the generation of the XML documentation:
SET(INTF_FILES)
ADD_FILES(INTF_FILES "../include/doxmlintf.h")
ADD_FILES(INTF_FILES "../interface/helpers.h")

SET(DOXY_PREDEFINED "")
GENERATE_REFLECTION(${TARGET_NAME} INTF_FILES)
